#include <iostream>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <string.h>
#include <algorithm>
using namespace std;

int n;
vector<pair<int, int>> v;
int l, w;
int ans = 0x3f3f3f;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> l >> w;
        v.push_back(make_pair(l, w));
    }
    while (next_permutation(v.begin(), v.end()))
    {
        int num = 1;
        for (int i = 0; i + 1 < v.size(); i++)
        {
            if (v[i].first >= v[i + 1].first && v[i].second >= v[i + 1].second)
                continue;
            else
                num++;
        }
        ans = min(ans, num);
    }
    cout << ans <<endl;
    //system("pause");
    return 0;
}